/**
 * 
 */
package com.coral.cstore.groups;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.coral.cstore.Style;
import com.coral.cstore.SysConstant;
import com.coral.cstore.utils.ImageUtils;
import com.coral.cstore.utils.StrUtils;
import com.coral.cstore.utils.WidgetUtils;

/**
 * @author coral.ma
 *
 */
public class ShotcutGroup {
	
	public String[] strings = {"menu.Biz.createCustomer.text","menu.Biz.mangCustomer","menu.Biz.createSupplier.text","menu.Biz.mangSupplier"};
	
	public String[] images = {"CreateCustomer","ManageCustomer","CreateSupplier","ManageSupplier"};
	
	public void initWidget(Shell shell) {
		GridData data = new GridData(GridData.FILL, GridData.FILL, true, false);
		// left size gird number of total grid number.
		data.horizontalSpan = 1;
		// the minimum size of left gird.
		data.minimumWidth =SysConstant.groupWidth;
		Group shotcutGroup = new Group(shell, SWT.SHADOW_IN);
		RowLayout layout = new RowLayout(SWT.VERTICAL);
		layout.spacing = 10;
		layout.marginTop = 10;
		layout.marginLeft = 10;
		shotcutGroup.setLayout(layout);
		shotcutGroup.setLayoutData(data);
		shotcutGroup.setText(StrUtils.getResourceString("group.title.shotcut"));
	    shotcutGroup.setBackground(Style.milkWhite);
//	    shotcutGroup.setFont(Style.groupTitleFont);
		Style.group(shotcutGroup);
		
		RowData rowData = new RowData(SysConstant.labelWidth, 20);
		
		for(int i=0;i<strings.length;i++) {
			final CLabel label = new CLabel(shotcutGroup, SWT.NONE);
			label.setLayoutData(rowData);
			label.setBackground(Style.milkWhite);
			label.setFont(Style.shotCutFont);
			label.setImage(ImageUtils.getImage(images[i]));
			label.setText("  "+StrUtils.getResourceString(strings[i]));
			label.addMouseTrackListener(new MouseTrackListener() {
				
				public void mouseHover(MouseEvent e) {
					System.out.println("mouseHover");
					label.setForeground(Style.gray);
				}
				
				public void mouseExit(MouseEvent e) {
					System.out.println("mouseExit");
					label.setForeground(Style.black);
				}
				
				public void mouseEnter(MouseEvent e) {
					System.out.println("mouseEnter");
					label.setForeground(Style.gray);
				}
			});
		}
	}
}
